<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-row>
      <el-col :span='22' :xs='24'>
        <el-form ref="form" :model="s_note" :rules="rules" label-width="100px" id="mvcfm">
          <el-button @click="gotoPage('/crm/sale/PotentialCustomerNMes?'+vueparams+'')" type='primary' size="mini">发送短信</el-button>
          <el-button @click="potentialCustomerMesSubmit('')" :disabled="multiple" type='success' size="mini"><i class='fa fa-check'></i>批量删除</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 发送情况 </span>
          </div>
          <el-table :data="s_note" @selection-change="handleSelectionChange">
            <el-table-column label="操作" align="center" width='100' type=''>
              <template slot-scope="scope">
                <el-dropdown trigger="click">
                  <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>
                      <el-link @click="d_note('&CMIDnote_id='+scope.row.note_id+'')">删除</el-link>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </template>
            </el-table-column>
            <el-table-column label="#" align="center" type='selection'>
            </el-table-column>
            <el-table-column label="短信电话" prop="note_id" c>
              <template slot-scope="scope">
                <el-link @click="gotoPage('/crm/sale/PotentialMessage?CMIDnote_id='+scope.row.note_id+''+vueparams+'')" c type='primary'>{{scope.row.number}}</el-link>
              </template>
            </el-table-column>
            <el-table-column label="短信标签" prop="suffix_name">
            </el-table-column>
            <el-table-column label="短信内容" prop="phones_message">
            </el-table-column>
            <el-table-column label="发送时间" prop="entered">
              <template slot-scope="scope">
                {{getDateTimeString(scope.row,'entered')}}
              </template>
            </el-table-column>
          </el-table>
          <pagination v-show="total>0" :total="total" :limit.sync="pageSize" @pagination="getPage" />
        </el-form>
      </el-col>
      <el-col :span='2' :xs='24'>
        <el-menu default-active='active' class='menu-unit'>
          <el-menu-item v-for='item in Container'>
            <el-link @click="gotoMenu(item.url)" :type="'短信'===item.name?'primary':'default'">{{item.page_desc||item.name}}</el-link>
          </el-menu-item>
        </el-menu>
      </el-col>
    </el-row>
  </div>
</template>
<script>
  import request from '@/utils/request'
  export default {
    name: 'PotentialCustomerMes',
    components: {},
    props: ['popparams'],
    data() {
      return {
        vueparams: this.getVUEParams(""),
        s_note: [],
        loading: false,
        Container: null,
        elcheck: [],
        multiple: true,
        rules: {}
      }
    },
    created() {
      this.getData();
      this.loadContainerMenu({
        pid: "80299289AF2443B18EA545A4C0C37170",
        name: "客户管理右菜单",
        selected: "短信"
      }, 'Container', this.vueparams);
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/crm/sale/PotentialCustomerMes/potentialCustomerMes?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      d_note(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/crm/sale/PotentialCustomerMes/d_note?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      potentialCustomerMesSubmit(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/crm/sale/PotentialCustomerMes/potentialCustomerMesSubmit?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.gotoPage("/crm/sale/PotentialCustomerNMes/potentialCustomerNMes?" + this.vueparams, data);
          this.msgSuccess(data.msg);
        })
      },
      handleSelectionChange(selection) {
        this.elcheck = selection.map(item => item["note_id"]);
        this.single = selection.length != 1;
        this.multiple = !selection.length;
      },
    },
  }
</script>
